# -*- coding: utf-8 -*-
"""
@Time ： 2022-09-05 16:31
@Auth ： Mr.Z
@Company ：test
@Function ：请输入模块功能描述
"""
from Keywords.inter_keys import Inter

inter = Inter()

# 正常登录
inter.set_url('http://testingedu.com.cn:8081/inter/HTTP/')
inter.post_data('auth')
inter.assert_equals('$.msg', 'success')
inter.save_json('token', 'newtoken')
inter.add_header('token', '{newtoken}')
inter.post_data('login', "username=Will&password=123456")    # 200 登陆成功
inter.post_data('login', "username=Will&password=123456")    # 406 用户已经登录
inter.post_data('logout')                                    # 200 退出登陆

# 异常登录
# 用户名字段：用户名错误，用户名为空，用户名字段不传，用户名边界值[3,16]
# inter.post_data('auth')
# inter.assert_equals('$.msg', 'success')
# inter.save_json('token', 'newtoken')
# inter.add_header('token', '{newtoken}')
# inter.post_data('login', "username=Wil1l&password=123456")   # 401 用户名密码错误
# inter.post_data('login', "username=&password=123456")        # 402 参数错误
# inter.post_data('login', "password=123456")                  # json处理异常
# inter.post_data('login', "username=wi&password=123456")      # 402 参数错误
# inter.post_data('login', "username=12345678901234567&password=123456")   # 402 参数错误
# inter.remove_header('token')
# inter.post_data('login', "username=Will&password=123456")    # 405 非法请求


# inter.set_url('http://testingedu.com.cn:8081/inter/HTTP')
# inter.post_data('auth')                                      # 200 token不存在或失效，创建token
# inter.assert_equals('$.msg', 'success')
# inter.save_json('token', 'newtoken')
# inter.add_header('token', '{newtoken}')
# inter.post_data('auth')                                      # 201 token未登陆
# inter.post_data('login', "username=Will&password=123456")    # 200 登陆成功
# inter.post_data('auth')                                      # 202 token已经授权登陆
# inter.post_data('logout')                                    # 200 退出登陆


# inter.set_url('http://testingedu.com.cn:8081/inter/HTTP')
# inter.post_data('auth')
# inter.assert_equals('$.msg', 'success')
# inter.save_json('token', 'newtoken')
# inter.add_header('token', '{newtoken}')
# inter.post_data('login', "username=큐〓㊚a&password=123456")
# inter.post_data('logout')


# inter.set_url('http://testingedu.com.cn:8081/inter/HTTP')
# inter.post_data('auth')
# inter.assert_equals('$.msg', 'success')
# inter.save_json('token', 'newtoken')
# inter.add_header('token', '{newtoken}')
# inter.post_data('login', "username=Will&password=123456")
# inter.save_json('userid', 'newid')
# inter.assert_equals('msg', '恭喜您，登录成功')
# inter.post_data("getUserInfo","id={newid}")
# inter.post_data("getUserInfo","id=2")
# inter.post_data("getUserInfo","id=1234567890")
# inter.post_data("getUserInfo","id=12345678901")
# inter.post_data('logout')
# inter.assert_equals('msg', '用户已退出登录')

# inter.set_url('http://testingedu.com.cn:8081/inter/HTTP')
# inter.post_data('auth')
# inter.assert_equals('$.msg', 'success')
# inter.save_json('token', 'newtoken')
#
# inter.add_header('token', '{newtoken}')
# inter.post_data('login', "password=123456")
# # inter.post_data('login', '{"password":"123456"}')
# # inter.post_data('login', '{"password":"123456"}')
# # inter.post_data('login', '{"username":"Will","password":"123456"}')
# inter.post_data('logout')
# inter.assert_equals('msg', '用户已退出登录')

# params = "aaa=222&password=123456"
# params = params.split('&')
# print(params)


# inter = Inter()
#
# # 正常登录
# inter.set_url('http://localhost:8000/mypro/api/user/')
# inter.post_json("login",'{"username":"will","pwd":123456}')


